<script type="text/javascript" class="source below">
// Note method 2) and 3) use `one`, this is because if `refresh` is called those events are triggered
$(function () {
	$("#demo2")
		.jstree({ "plugins" : ["themes","html_data","ui"] 
        })
		// 1) the loaded event fires as soon as data is parsed and inserted
		.bind("loaded.jstree", function (event, data) {})
		// 2) but if you are using the cookie plugin or the core `initially_open` option:
		.one("reopen.jstree", function (event, data) { })
		// 3) but if you are using the cookie plugin or the UI `initially_select` option:
		.one("reselect.jstree", function (event, data) { })
                .bind("select_node.jstree", function (event, data) { 
            
                });

});

	$(document).ready(function(){	
		//default usage
		//$("#news_form_metaDescription").charCount();
		//custom usage
		$("#news_form_metaDescription").charCount({
			allowed: 70,		
			warning: 20,
			counterText: 'Characters left: '	
		});
                $("#news_form_content").charCount({
			allowed: 200,		
			warning: 50,
			counterText: 'Characters left: '	
		});

	});
    
</script>
 <div class="title"><h5>Tables examples</h5></div>
   {{ form_start(form, {'attr': {'class': 'mainForm ui-formwizard', 'id': 'wizForm', 'action': path('em_news')}}) }}
     <div class="widget">   
      <div class="head"></div>
     <fieldset class="step ui-formwizard-content" id="first" style="display: block;">
        <h5>Create content </h5>
    <script type="text/javascript" src="{{ asset('bundles/news/js/nicEdit-latest.js') }}"></script>
   
	
	 {% if status_form==1 %}
	 <div class="nNote nSuccess hideit">
                <p><strong>SUCCESS: </strong> The original content has been created.</p>
         </div>
	
	{% elseif status_form==2 %}
	<div class="nNote nFailure hideit">
		<p><strong>FAILURE: </strong>Oops sorry. Something went wrong, try again.</p>
	</div>
	 {% endif %}
	
   
                                <div class="rowElem">
				<label>Title<span class="req">*</span></label>
				<div class="formRight">{{ form_widget(form.title) }}</div>
				<div class="formRight">{{ form_errors(form.title) }}</div>
				<div class="fix"></div>
				</div> 
                                <div class="rowElem">
				<label>Title SEO<span class="req">*</span></label>  
				<div class="formRight">{{ form_widget(form.titleSeo) }}</div>
				<div class="formRight">{{ form_errors(form.titleSeo) }}</div>
				<div class="fix"></div>
				</div> 
 
                                <div class="rowElem">
				<label>Meta Description</label>
				<div class="formRight">{{ form_widget(form.metaDescription) }}</div>
				<div class="formRight">{{ form_errors(form.metaDescription) }}</div>
				<div class="fix"></div>
				</div> 
			
            
				<div class="rowElem">
							{{ form_widget(form.content) }}
							{{ form_errors(form.content) }}
				</div>	
              </fieldset>
              <fieldset class="step ui-formwizard-content" id="second" style="display: none;">
              
                {%if form.vars.value.keywords ==1%}
                <div class="rowElem">
					
                       <label>Categories:</label>
                        <div class="formRight">
                            <select data-placeholder="Select categories for this post" style="" class="chzn-select" multiple="multiple" tabindex="6" name="cat[]">
                            {% for key, category in categories%}
                              {% if category.level==0 %}
                              <option value="{{category.id}}">{{ category.name}}</option>
                              
                              {% for cat in categories%}
                              {% if cat.categoryParent!=null%}
                              {% if category.id==cat.categoryParent.id%}
                                <option value="{{cat.id}}">&nbsp; {{  cat.name}}</option>
                               {% for   subcat in categories%}
                                 {% if subcat.categoryParent!=null%}
                                   {% if cat.id==subcat.categoryParent.id%}
                                     <option value="{{subcat.id}}">&nbsp;&nbsp; {{  subcat.name}}</option>
                                     {% for   subscat in categories%}
                                        {% if subscat.categoryParent!=null%}
                                            {% if subcat.id==subscat.categoryParent.id%}
                                             <option value="{{subscat.id}}">&nbsp;&nbsp;&nbsp;&nbsp; {{  subscat.name}}</option>
                                            {%endif%}
                                        {%endif%}
                                     {% endfor%}
                                   {%endif%}
                                  {%endif%}
                               {% endfor%}
                              {% endif%}
                              {% endif%}
                              {% endfor%}
                              {% endif %}
                            {% endfor %}
                                
                            </select>  
                        </div>  

                        <div class="fix"></div>
		</div>
             
               <div class="rowElem">
                <label>Image Url: <span class="req">*</span></label>
                <div class="formRight">
                {{ form_widget(form.image) }}
                {{ form_errors(form.image) }}
                </div>
                </div>
                <div class="rowElem">
                <label>Source: <span class="req">*</span></label>
                <div class="formRight">
                {{ form_widget(form.source) }}
                {{ form_errors(form.source) }}
                </div>
                </div>
                <div class="rowElem">
                <label>url: <span class="req">*</span></label>
                <div class="formRight">
                {{ form_widget(form.url) }}
                {{ form_errors(form.url) }}
                </div>
                
                </div>
                   {%endif%}
                <div class="rowElem">
                <label>Status: <span class="req">*</span></label>
                <div class="formRight">
                {{ form_widget(form.status) }}
                {{ form_errors(form.status) }}
                </div>
                </div>
		 <input type="hidden" id="author" name="author" value="{{app.user.id}}">		
		
            </fieldset>
            <div class="wizNav"> 							
                <input class="basicBtn ui-wizard-content ui-formwizard-button" id="back" value="Back" type="reset" disabled="disabled">
                <input class="blueBtn ui-wizard-content ui-formwizard-button" id="next" value="Next" type="submit">
            </div>
      </div>
		<!--	  </form>-->
              {{ form_end(form) }} 
<script>
$('#news_form_content').wysihtml5();

$( "#news_form_title" ).focusout(function() {
  //  $( "#news_form_slug" ).val( "focusout fired:" );
  var slug=this.value;
  console.log(slug);
  $( "#news_form_titleSeo" ).val(slug);
  });

</script>
